package com.ymm.web.controller;

import com.ymm.platform.api.constants.dto.QueryDriverDTO;
import com.ymm.platform.api.constants.dto.QueryShipperDTO;
import com.ymm.platform.api.facade.PlatformQueryDriverService;
import com.ymm.platform.api.facade.PlatformQueryShipperService;
import com.ymm.platform.api.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Company: CUG
 * @Description: TODO
 * @Author: chencong
 * @Date: 2022-08-15 22:23
 **/
@CrossOrigin
@RestController
@Slf4j
@RequestMapping("/platform/shipper")
public class ShipperController {
    @Reference
    private PlatformQueryShipperService platformQueryShipperService;
    /**
    * @Author: chencong
    * @Description: 分页获取所有货主信息
    * @DateTime: 14:05 2022/8/16
    * @Params: [pageNum, pageSize]
    * @Return com.ymm.platform.api.utils.Result
    */
    @RequestMapping("/getShipper")
    public Result queryAllDriver(Integer pageNum, Integer pageSize) {

        return platformQueryShipperService.queryAllShipper(pageNum,pageSize);
    }

    /**
    * @Author: chencong
    * @Description: 按条件分页查询货主
    * @DateTime: 14:05 2022/8/16
    * @Params: [pageNum, pageSize, queryShipperDTO]
    * @Return com.ymm.platform.api.utils.Result
    */
    @RequestMapping("/getShipperOnC")
    public Result queryDriverOnCondition(Integer pageNum, Integer pageSize, QueryShipperDTO queryShipperDTO){
        try{
            return platformQueryShipperService.queryShipperOnCondition(pageNum,pageSize,queryShipperDTO);
        }catch (Exception e){
            return Result.fail("信息不对");
        }
    }

    /**
    * @Author: chencong
    * @Description: 获取某个司机完单总数
    * @DateTime: 14:08 2022/8/16
    * @Params: [shipperId]
    * @Return com.ymm.platform.api.utils.Result
    */
    @RequestMapping("/getShipperCOrder")
    public Result queryShipperCompleteOrder(Long shipperId){
        return platformQueryShipperService.queryShipperCompleteOrder(shipperId);
    }

    /**
    * @Author: chencong
    * @Description: 分页获取某个司机完单列表
    * @DateTime: 14:09 2022/8/16
    * @Params: [pageNum, pageSize, shipperId]
    * @Return com.ymm.platform.api.utils.Result
    */
    @RequestMapping("/getShipperCOrderL")
    public Result queryShipperCompleteOrderList(Integer pageNum, Integer pageSize,Long shipperId){
        return platformQueryShipperService.queryShipperCompleteOrderList(pageNum,pageSize,shipperId);
    }

    /**
    * @Author: chencong
    * @Description: 获取某个司机取消订单总数
    * @DateTime: 14:13 2022/8/16
    * @Params: [shipperId]
    * @Return com.ymm.platform.api.utils.Result
    */
    @RequestMapping("/getShipperUcOrder")
    public Result queryShipperUncompleteOrder(Long shipperId){
        return platformQueryShipperService.queryShipperUncompleteOrder(shipperId);
    }

    /**
    * @Author: chencong
    * @Description: 分页获取某个司机取消订单列表
    * @DateTime: 14:14 2022/8/16
    * @Params: [pageNum, pageSize, shipperId]
    * @Return com.ymm.platform.api.utils.Result
    */
    @RequestMapping("/getShipperUcOrderL")
    public Result queryShipperUncompleteOrderList(Integer pageNum, Integer pageSize,Long shipperId){
        return platformQueryShipperService.queryShipperUncompleteOrderList(pageNum,pageSize,shipperId);
    }

    /**
    * @Author: chencong
    * @Description: 获取司机的发货总支出
    * @DateTime: 14:15 2022/8/16
    * @Params: [shipperId]
    * @Return com.ymm.platform.api.utils.Result
    */
    @RequestMapping("/getShipperOut")
    public Result queryShipperTotalOutcome(Long shipperId){
        return platformQueryShipperService.queryShipperUncompleteOrder(shipperId);
    }

    /**
    * @Author: chencong
    * @Description: 获取货主发布货源总数
    * @DateTime: 14:17 2022/8/16
    * @Params: [shipperId]
    * @Return com.ymm.platform.api.utils.Result
    */
    @RequestMapping("/getShipperTShip")
    public Result queryShipperTotalShipments(Long shipperId){
        return platformQueryShipperService.queryShipperTotalShipments(shipperId);
    }
    
    
    /**
    * @Author: chencong
    * @Description: 获取货主发布货源列表
    * @DateTime: 14:40 2022/8/16
    * @Params: [pageNum, pageSize, shipperId]
    * @Return com.ymm.platform.api.utils.Result
    */
    @RequestMapping("/getShipperTShipL")
    public Result queryShipperPublishCargo(Integer pageNum, Integer pageSize,Long shipperId){
        return platformQueryShipperService.queryShipperPublishCargo(pageNum,pageSize,shipperId);
    }

    /**
    * @Author: chencong
    * @Description: 通过姓名查询货主
    * @DateTime: 19:53 2022/8/18
    * @Params: [pageNum, pageSize, shipperName]
    * @Return com.ymm.platform.api.utils.Result
    */
    @RequestMapping("/getShipperByName")
    public Result queryShipperListByName(Integer pageNum,Integer pageSize,String shipperName) {
        if(shipperName.equals(null)){
            return platformQueryShipperService.queryAllShipper(pageNum,pageSize);
        }
        return platformQueryShipperService.queryShipperListByName(pageNum,pageSize,shipperName);
    }

    /**
    * @Author: chencong
    * @Description: 通过手机号查询货主
    * @DateTime: 19:53 2022/8/18
    * @Params: [pageNum, pageSize, shipperPhoneNum]
    * @Return com.ymm.platform.api.utils.Result
    */
    @RequestMapping("/getShipperByPhone")
    public Result queryShipperListByPhone(Integer pageNum,Integer pageSize,String shipperPhoneNum) {
        return platformQueryShipperService.queryShipperListByPhone(pageNum,pageSize,shipperPhoneNum);
    }

    /**
    * @Author: chencong
    * @Description: 按照货主会员等级升序排列
    * @DateTime: 10:35 2022/8/19
    * @Params: [pageNum, pageSize, asc]
    * @Return com.ymm.platform.api.utils.Result
    */
    @RequestMapping("/sortShipperByA")
    public Result sortShipperByVipTypeA(Integer pageNum,Integer pageSize,Integer asc) {
        return platformQueryShipperService.sortShipperByVipTypeA(pageNum,pageSize,asc);
    }

    /**
    * @Author: chencong
    * @Description: 按照货主会员等级降序排列
    * @DateTime: 10:35 2022/8/19
    * @Params: [pageNum, pageSize, desc]
    * @Return com.ymm.platform.api.utils.Result
    */
    @RequestMapping("/sortShipperByD")
    public Result sortShipperByVipTypeD(Integer pageNum,Integer pageSize,Integer desc) {
        return platformQueryShipperService.sortShipperByVipTypeA(pageNum,pageSize,desc);
    }

}
